package com.kis.thread;

/**
 * Created by yks on 15-11-13.
 */
class task implements Runnable{
    private int ticket=10;
    public void run() {
        for (int i = 0; i < 20; i++) {
            if(ticket>0){
                System.out.println(Thread.currentThread().getName()+" sold ticket "+ticket--);
            }
        }
    }
}
public class TestThread {
    public static void main(String[] args) {
        task t = new task();
        Thread thread  = new Thread(t);
        Thread thread1  = new Thread(t);
        Thread thread2  = new Thread(t);
        thread.start();
        thread1.start();
        thread2.start();
    }
}

